<?php

namespace App\Modules\MessageHandler;

use App\Modules\MessageHandler\Handlers\TextHandler;
use App\Modules\User\Models\User;
use Log;

class Manager
{
    public static function handle($message)
    {
        if (is_null($message['MsgType'])) {
            return null;
        }
        if ($message['MsgType'] == 'event' && $message['Event'] == 'TEMPLATESENDJOBFINISH') {
            return null;
        }
        /** @var User $user */
        $user = User::query()
            ->where('openid', $message['FromUserName'])
            ->first();
        switch ($message['MsgType']) {
            case 'event':
                return null;
            case 'text':
                return TextHandler::handle($message, $user);
            case 'image':
                return null;
            case 'voice':
                return null;
            case 'video':
                return null;
            case 'location':
                return null;
            case 'link':
                return null;
            default:
                return null;
        }
    }
}
